<?php if($action == 'bycat'):?>
   <div class="grid_12">
        <ul class="grid-list">
        <?php foreach($products['data'] as $key => $product):?>
            <?php echo ($key%3 == 0)? App::Helper('Html')->getTag('li',Array('class'=>'pborderb')) : App::Helper('Html')->getTag('li',Array('class'=>'pborderlb'));?>
                <a href="<?php echo App::Config()->baseUrl("/item-detail/{$product['id']}/" . App::Helper('Utility')->text2Normalize($product['title'])) ?>">
                    <?php echo App::Helper('Html')->imgTag($product['imagethumb'],array('mode'=>'imagemanager'),array('class'=>'box','width'=>'100'));?></a><br />
                <strong><?php echo $this->__('Price');?> : <?php echo( App::Helper('Config')->setting('currency','$') . App::Component('appStore')->Helper('data')->currencyFormate($product['price']));?></strong>
                <h3>
                    <a href="<?php echo App::Config()->baseUrl("/item-detail/{$product['id']}/" . App::Helper('Utility')->text2Normalize($product['title'])) ?>">
						<?php echo($product['title']);?>
                    </a>
                </h3>
                <div class="add2cartwrapper align-center">
                    <?php App::Hook('UI')->Render('appstore_checkout_button_left',$product); ?>
					<a href="<?php echo App::Config()->baseUrl("/item-detail/{$product['id']}/" . App::Helper('Utility')->text2Normalize($product['title'])) ?>" class="button white medium"><?php echo $this->__("Buy Now");?></a>
                    <?php App::Hook('UI')->Render('appstore_checkout_button_right',$product); ?>
                </div>	
            </li>
        <?php endforeach;?>
        </ul>
        <br class="clear" />
        <?php if($products['paging']!=''):?>
            <p><?php echo $products['link']; ?></p>
        <?php endif;?>
        <br class="clear" />
		<br />
        <div class="grid_5">
            <input type="button" value="Continue checkout" class="checkout-button button green medium <?php echo (App::Component('appStore')->Helper('Data')->isToCheckout()) ? "show" : "hide";?>" />
        </div>
	</div>
<?php elseif($action == 'byprod'):?>	
	<?php if(strtolower($product['slidetype']) != 'none'):?>
    <div class="grid_8">          
		<?php if($product['slidetype'] == 'Zoom'):?>	
			<script type="text/javascript">
				jQuery(document).ready(function () {
					jQuery("#zoom").elevateZoom({gallery:'gal1', cursor: 'pointer',easing : true,zoomWindowWidth:460,zoomWindowOffetx:10}); 
					jQuery("#zoom").bind("click", function(e) {  
						var ez =   jQuery('#zoom').data('elevateZoom');	
						jQuery.fancybox(ez.getGalleryList());
						return false;
					}); 
				}); 
			</script>
			<?php $imagelist = explode(',',$product['imagelist']);?>	
			<?php if(!empty($product['imagelist']) && isset($imagelist[1]) && $imagelist[2]):?>
				<img class="product-detail" width="450" id="zoom" src="<?php echo App::Config()->baseUrl("/uploads/filemanager/{$imagelist[1]}");?>" data-zoom-image="<?php echo App::Config()->baseUrl("/uploads/filemanager/{$imagelist[2]}");?>"/>
				<?php if(count($imagelist)>3):  ?>	
					<div id="gal1">
						<?php for($ii=0; $ii < count($imagelist); $ii += 3):?>
						<?php if(isset($imagelist[$ii+2])):?>
							<a href="#" data-image="<?php echo App::Config()->baseUrl("/uploads/filemanager/" . $imagelist[$ii+1]);?>" data-zoom-image="<?php echo App::Config()->baseUrl("/uploads/filemanager/" . $imagelist[$ii+2]);?>">
								<img width="88" src="<?php echo App::Config()->baseUrl("/uploads/filemanager/" . $imagelist[$ii]);?>" />
							 </a>					
						<?php endif;?>
						<?php endfor;?>
					</div>	
				<?php endif;?>
			<?php endif;?>
		<?php elseif($product['slidetype'] == 'NewWindow'):?>	
			<script type="text/javascript">
				jQuery(document).ready(function () {					
					jQuery("#zoom").bind("click", function(e) {  
						jQuery.fancybox(
							jQuery('<img />').attr({ 'src': '<?php echo App::Config()->baseUrl("/uploads/filemanager/{$product['imagelist']}");?>'})
						);
						return false;
					});
					
				}); 
			</script>
			<img class="product-detail" width="450" id="zoom" src="<?php echo App::Config()->baseUrl("/uploads/filemanager/{$product['image']}");?>" data-zoom-image="<?php echo App::Config()->baseUrl("/uploads/filemanager/{$product['image']}");?>"/>			
		<?php elseif($product['slidetype'] == 'StaticImage'):?>	
			<img class="product-detail" width="450" src="<?php echo App::Config()->baseUrl("/uploads/filemanager/{$product['image']}");?>" data-zoom-image="<?php echo App::Config()->baseUrl("/uploads/filemanager/{$product['image']}");?>"/>						
		<?php endif;?>
    </div>
	<?php endif;?>
	
    <div class="grid_8">
			<h2><?php echo($product['title']); ?></h2>
			<?php if($product['features'] != ''):?>
				<?php echo  App::Component('Appstore')->Helper('Common')->getProductFeatureTable($product,true);?>
			<?php endif;?>
	</div>
	<div class="clear"></div>
	<div class="appstore-divider"></div>
	<h3 class="block-title">Product Detail</h3>
	<div class="grid_8" >		
			<div class="productpricebox">
				<?php echo  App::Component('Appstore')->Helper('Common')->getPricebox($product);?>
			</div>		
			<?php if($product['description']!=''):?>
				<div class="appstore-divider"></div>
				<?php echo nl2br($product['description']); ?>				
			<?php endif;?>		
			<div class="appstore-divider"></div>
            <p class="add2singleproduct">
                <input type="hidden" size="2" value="<?php echo $product['id']; ?>" class="productid" />
                <?php App::Hook('UI')->Render('appstore_checkout_button_left',$product); ?>
                <input type="text" size="2" value="<?php echo App::Component('appStore')->Helper('Data')->getCartInfoByProductId($product['id'])?>" class="add2cart-input" />
                <input type="submit" value="Add to Basket" class="add2cart-button button red medium" />
                <input type="button" onclick="javascript:history.go(-1)" class="button medium orange" value="Continue Shopping">
                <input type="button" value="Checkout" class="checkout-button button medium green <?php echo (App::Component('appStore')->Helper('Data')->isToCheckout()) ? "show" : "hide";?>" />
                <?php App::Hook('UI')->Render('appstore_checkout_button_right',$product); ?>
            </p>
    </div>
	<div class="grid_8">
		<div class="attributebox">
		<?php if($product['promotext']!=''):?>
			<h3><?php echo $product['promotext'];?></h3>			
		<?php endif;?>
			<div class="error-attribute"></div>					
			<form method="post" id="checkattributeforvalue" action="<?php echo App::Config()->baseUrl("/appstore/checkattributeforvalue/{$product['attributegroup']}");?>">
				<?php echo App::Component('appStore')->Helper('Common')->attributeInHtml($product)?>
			</form>
		</div>
	</div>	
	
	<?php if($product['galleryimagelist'] !=''):?>
		<div class="appstore-divider clear"></div>
		<h3 class="block-title"><?php echo $this->__('Gallery');?></h3>
		<div class="grid_16 align-center">	
			<div class="storeslideshow">
			<?php foreach(explode(',',$product['galleryimagelist']) as $img): ?>
				<img src="<?php echo App::Config()->filemanagerUrl("/{$img}");?>" width="900" />
			<?php endforeach;?>
			</div>
			<script type="text/javascript">
				jQuery(document).ready(function() {
					jQuery('.storeslideshow').cycle( {timeout: 1000, next:'#next2',prev:'#prev2'});
				});
			</script>
			
			<a href="javascript:void(0)" id="prev2"><?php echo $this->__('Previous');?></a>
			<a href="javascript:void(0)" id="next2"><?php echo $this->__('Next');?></a>
		</div>
	<?php endif;?>
		
	<?php if(($reletedProductStr =  App::Component('Appstore')->Helper('Common')->getRelatedProduct($product)) != ''):?>
		<div class="appstore-divider clear"></div>
		<h3 class="block-title"><?php echo $this->__('Other product of this merchant');?></h3>
		<div class="grid_16">
			<?php echo $reletedProductStr;?>
		</div>
	<?php endif;?>
	
	<?php if(App::Config()->setting('store_disable_customer_review','No') != 'Yes'):?>
		<div class="appstore-divider clear"></div>
		<h3 class="block-title"><?php echo $this->__('Customer Review');?></h3></h3>
		<div class="grid_9">
			<h2><?php echo $this->__("Comments");?></h2>
            <?php if(!empty($comments['data'])):?>
                <ul>
                <?php foreach($comments['data'] as $key=>$comment):?>
                    <li>
                        <p class="comment-short-info" id="comment-parma-link<?php echo ($key+1); ?>">
                            <strong><?php echo App::Helper('Html')->linkTag($comment['website'],$comment['name'],Array("rel"=>"nofollow")); ?></strong>
                            <?php echo $this->__("Says On");?> <?php echo App::Helper('Date')->dateFormated($comment['dated'],'long'); ?>
							<?php echo App::Helper('Html')->linkTag("#comment-parma-link" . ($key+1),'&#10144;'); ?>
							<?php echo($comment['rate']);?>
							</p>
                        <p><?php echo($comment['comment']);?></p>
                    </li>
                <?php endforeach;?>
                </ul>
            <?php else:?>
                <p><?php echo $this->__("No comment posted yet"); ?></p>
            <?php endif;?>
		</div>
		<div class="grid_7">
			<div class="message comment-message"></div>
            <form method="post" id="product-review" action="<?php echo $this->baseurl("/appstore/customer-review/{$id}") ?>" class="store-form">
            <ul>
                <li><label><?php echo $this->__('Name');?></label><span><input type="text" name="data[StoreComment][name]" class="input check_notempty" longdesc="Please enter your name." value="" /></span></li>
                <li><label><?php echo $this->__('Email Address');?></label><span><input type="text" name="data[StoreComment][email]" class="input check_email" longdesc="Please enter your valid email address." value="" /></span></li>
                <li><label><?php echo $this->__('Rate');?></label><span><?php echo App::Html()->selectTag("data[StoreComment][rate]",array("1"=>"One","2"=>"Two","3"=>"Three","4"=>"Four","5"=>"Five"),null,array("class"=>"check_notempty"));?></span></li>
                <li><label><?php echo $this->__('StoreComments');?></label><span><textarea name="data[StoreComment][comment]" class="input check_notempty" longdesc="Please type your comment here." rows="5"></textarea></span></li>
                <li><label>&nbsp;</label><label><?php echo App::Helper('Html')->capachaTag("storecommet",Array("bk_color"=>"#000000","font_color"=>"#FFFFFF"));?></label></li>
				<li><label><?php echo $this->__('Security Code');?></label><span><input type="text" name="data[StoreComment][capacha]" class="input small check_notempty" longdesc="Please fillin the text display on left side image." value="" /></span></li>
                <li><label>&nbsp;</label><span><input type="submit" value="Submit" class="button white medium" /></span></li>
            </ul>
            </form>
             <?php  App::Helper('JavaScript')->setAjax(array("debug"=>false,"autoHide"=>true))->appForm('#product-review');?>			
		</div>	
	<?php endif;?>		
<?php else:?>
	<div class="grid_12">
        <?php if(App::Config()->siteInfo('storeslidesettings_enable',false) != 'No'):?>
            <div class="storeslideshow">
            <?php foreach($storeslides['data'] as $slide):?>
                <img src="<?php echo App::Config()->filemanagerUrl("/{$slide['image']}");?>" /> 
            <?php endforeach;?>
            </div>
            <?php 
                echo App::Helper('JavaScript')->Cycle(
                    '.storeslideshow',
                    (App::Config()->siteInfo('storeslidesettings_tmode',false) == 'customcode' )
                        ? App::Config()->siteInfo('storeslidesettings_customcode',false)
                        : App::Config()->siteInfo('storeslidesettings_tmode',false)
                );
            ?>
        <?php endif;?>
			<h3 class="feature-products-title"><?php echo $this->__('Featured Products');?></h3>
			<div class="divider"></div>
			<ul class="grid-list glitter">
			<?php foreach($products['data'] as $key => $product):?>
				<?php echo ($key%3 == 0)? App::Helper('Html')->getTag('li',Array('class'=>'pborderb')) : App::Helper('Html')->getTag('li',Array('class'=>'pborderlb'));?>
					<a href="<?php echo App::Config()->baseUrl("/item-detail/{$product['id']}/" . App::Helper('Utility')->text2Normalize($product['title'])) ?>">
					<?php echo App::Helper('Html')->imgTag($product['imagethumb'],array('mode'=>'imagemanager'),array('class'=>'box','width'=>'100'));?></a><br />
					<?php echo($product['title']);?>
					<p>					
						<strong>Price : <?php echo( App::Helper('Config')->setting('currency','$') . App::Component('appStore')->Helper('data')->currencyFormate($product['price']));?></strong>
					</p>
					<p>
						<a href="<?php echo App::Config()->baseUrl("/item-detail/{$product['id']}/" . App::Helper('Utility')->text2Normalize($product['title'])) ?>" class="button white small orange"><?php echo $this->__("Buy Now");?></a>
					</p>
				</li>
			<?php endforeach;?>
			</ul>
	</div>
<?php endif;?>

<?php if($action != 'byprod'):?>
<div class="grid_4">
    <div class="list">
        <?php App::Hook('UI')->Render('template_left_column_A'); #User Interface Hook ?>
        <?php App::Hook('UI')->Render('template_left_column_B'); #User Interface Hook ?>
        <?php $Categories = App::Component('Appstore')->Helper('Data')->caregoryList();?>
		<ul class="list">
		<?php foreach($Categories as $Category):?>
			<li><a href="<?php echo App::Config()->baseUrl("/category-view//{$Category['id']}/" . App::Helper('Utility')->text2Normalize($Category['title'])) ?>"><?php echo($Category['title']);?></a></li>
		<?php endforeach;?>
		</ul>
        <?php App::Hook('UI')->Render('template_left_column_C'); #User Interface Hook ?>
        <?php App::Hook('UI')->Render('template_left_column_D'); #User Interface Hook ?>
    </div>
</div>
<?php endif;?>